package per.liu.web;

import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.cas.CasRealm;
import org.apache.shiro.subject.PrincipalCollection;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by liuj on 2015/6/23.
 */
public class MyCasRealm extends CasRealm {


    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        String username = (String) principals.getPrimaryPrincipal();
        SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
        Set<String> roles = new HashSet<String>();
        roles.add(username);
        authorizationInfo.setRoles(roles);
        Set<String> perms = new HashSet<String>();
        perms.add(username + "Perm:ALL");
        authorizationInfo.setStringPermissions(perms);
        return authorizationInfo;
    }


}
